package com.tangcan.blog.Mapper;

import com.tangcan.blog.Entity.Comment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {


    @Select("SELECT * FROM Comment")
    List<Comment> GetAll();

    @Select("SELECT * FROM Comment WHERE Id = #{Id}")
    Comment GetCommentById(int Id);

    @Select("SELECT * FROM Comment WHERE BlogId = #{BlogId}")
    List<Comment> GetBlogComment(int BlogId);

    @Insert("INSERT INTO Comment (Comment,UserId,Time,BlogId,UserName) VALUES (#{Comment},#{UserId},#{Time},#{BlogId},#{UserName})")
    int AddComment(Comment comment);

    @Update("UPDATE Comment SET Comment = #{Comment} WHERE Id = #{Id}")
    int UpdateComment(Comment comment);

    @Delete("DELETE FROM Comment WHERE Id = #{Id}")
    int RemoveComment(int Id);
}
